package com.wypiwyl.footastic.view;

import com.wypiwyl.footastic.Player;
import com.wypiwyl.footastic.PlayerKey;

public class Flags {

    // instance du singleton
    private static Flags instance;

    /** **/
    //
    private boolean playerSelected = false;
    private PlayerKey playerKeySelected = null;
    //
    private boolean ballSelected = false;
    //
    private boolean passSelected = false;
    private Option typePassSelected;
    //

    private boolean teamATurn = true;
    private boolean teamBTurn = false;

    private boolean teamAShowMove = true;
    private boolean teamBShowMove = false;
    
    private boolean passeDone = false;
    
    
    

    public boolean isPasseDone() {
        return passeDone;
    }

    public void setPasseDone(boolean passeDone) {
        this.passeDone = passeDone;
    }

    private Flags() {

    }

    public static Flags getInstance() {
        // verification de l'existence du singleton
        if (instance == null) {
            instance = new Flags();
        }
        // renvoi du singleton
        return instance;
    }

    public void initRound() {
        /** Equipe A **/
        // on indique que c'est au tour de l'equipe A
        teamATurn = true;
        // on indique que l'on montre les actions de l'equipe A
        teamAShowMove = true ;
        
        /** Equipe B **/
        // on indique que c'est pas au tour de l'equipe B
        teamBTurn = false;
        // on indique que l'on ne montre pas les actions de l'equipe B
        teamBShowMove = false;
    }

//    public void endRoundTeamA() {
//        /** Equipe A **/
//        // on indique que ce n'est pas au tour de l'equipe A
//        teamATurn = false;
//        // on indique que l'on ne montre pas les actions de l'equipe A
//        teamAShowMove = false ;
//        /** Equipe B **/
//        // on indique que c'est au tour de l'equipe B
//        teamBTurn = true;
//        // on indique que l'on montre les actions de l'equipe B
//        teamBShowMove = true;
//    }
    
//    public void endRoundTeamB() {
//        /** Equipe A **/
//        // on indique que l'on montre les actions de l'equipe A
//        teamAShowMove = true;
//        /** Equipe B **/
//        // on indique que ce n'est plus le tour de l'equipe B
//        teamBTurn = false;
//        // on indique que l'on montre les actions de l'equipe B
//        teamBShowMove = true;
//    }
    
//    public boolean isPlayerTurn(Player player) {
//        return ((player.isbTeamA() && teamATurn)
//        || (!player.isbTeamA() && teamBTurn));
//    }
//    
//    public boolean isPlayerShow(Player player) {
//        return ((player.isbTeamA() && teamAShowMove)
//        || (!player.isbTeamA() && teamBShowMove));
//    }

    public boolean isPlayerSelected() {
        return playerSelected;
    }

    public void selectPlayer() {
        this.playerSelected = true;
    }

    public void unselectPlayer() {
        this.playerSelected = false;
        // automatiquement la cle du joueur est reinitialisee
        initPlayerKeySelected();
        // automatiquement le ballon n'est plus selectionne
        unselectBall();
    }

    public PlayerKey getPlayerKeySelected() {
        return playerKeySelected;
    }

    public void addPlayerKeySelected(PlayerKey playerKeySelected) {
        this.playerKeySelected = playerKeySelected;
    }

    public void initPlayerKeySelected() {
        this.playerKeySelected = null;
    }

    public boolean isBallSelected() {
        return ballSelected;
    }

    public void selectBall() {
        this.ballSelected = true;
    }

    public void unselectBall() {
        this.ballSelected = false;
        // automatiquement l'option passe n'est plus selectionnee
        unselectPass();
    }

    public boolean isPassSelected() {
        return passSelected;
    }

    public void selectPass() {
        this.passSelected = true;
    }

    public void unselectPass() {
        this.passSelected = false;
        // automatiquement le type de passe est reinitialise
        initTypePassSelected();
    }

    public Option getTypePassSelected() {
        return typePassSelected;
    }

    public void addTypePassSelected(Option typePassSelected) {
        this.typePassSelected = typePassSelected;
    }

    public void initTypePassSelected() {
        this.typePassSelected = null;
    }

//    public boolean isTeamATurn() {
//        return teamATurn;
//    }
//
//    public void setTeamATurn(boolean teamATurn) {
//        this.teamATurn = teamATurn;
//    }
//
//    public boolean isTeamBTurn() {
//        return teamBTurn;
//    }
//
//    public void setTeamBTurn(boolean teamBTurn) {
//        this.teamBTurn = teamBTurn;
//    }
//
//    public boolean isTeamAShowMove() {
//        return teamAShowMove;
//    }
//
//    public void setTeamAShowMove(boolean teamAShowMove) {
//        this.teamAShowMove = teamAShowMove;
//    }
//
//    public boolean isTeamBShowMove() {
//        return teamBShowMove;
//    }
//
//    public void setTeamBShowMove(boolean teamBShowMove) {
//        this.teamBShowMove = teamBShowMove;
//    }

}
